home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Developers / YAAF v1.0 alpha 1 / Headers / Core / XDataUtil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-24  |  3.9 KB  |  149 lines

  1. /*    XDataUtil.h
  2.  *
  3.  *        The data manipulation utilities. I wrote my own because I'm
  4.  *    one of those obnoxious types who likes to know what's going on.
  5.  *
  6.  *    Copyright (C) 1997 by William Edward Woody and In Phase Consulting,
  7.  *    all rights reserved.
  8.  */
  9.  
  10. /*  YAAF - Yet another application framework
  11.  *  Copyright (C) 1997 William Edward Woody and In Phase Consulting
  12.  *  
  13.  *  This library is free software; you can redistribute it
  14.  *  and/or modify it under the terms of the GNU Library
  15.  *  General Public License as published by the Free Software
  16.  *  Foundation; either version 2 of the License, or any
  17.  *  later version.
  18.  *  
  19.  *  This library is distributed in the hope that it will be
  20.  *  useful, but WITHOUT ANY WARRANTY; without even the implied
  21.  *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
  22.  *  PURPOSE. See the GNU Library General Public License for
  23.  *  more details.
  24.  *  
  25.  *  You should have received a copy of the GNU Library General
  26.  *  Public License along with this library; if not, write to the
  27.  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  28.  *  Boston, MA 02111-1307, USA.
  29.  *  
  30.  *  To contact the author, either e-mail me at
  31.  *  woody@alumni.caltech.edu, or write to us at
  32.  *  
  33.  *          William Edward Woody
  34.  *          In Phase Consulting
  35.  *          1545 Ard Eevin Avenue
  36.  *          Glendale, CA 91202
  37.  */
  38.  
  39. #ifndef __XDATAUTIL_H__
  40. #define __XDATAUTIL_H__
  41.  
  42. #ifndef __XCONFIG_H__
  43. #include <XConfig.h>
  44. #endif
  45.  
  46. #if defined(__MWERKS__)
  47.     #if defined(macintosh)
  48.         #pragma options align=power
  49.     #endif
  50.     #if defined(__INTEL__)
  51.         #pragma pack(push,2)
  52.     #endif
  53. #endif
  54.  
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58.  
  59.  
  60. /************************************************************************/
  61. /*                                                                        */
  62. /*    short/long compression                                                */
  63. /*                                                                        */
  64. /************************************************************************/
  65.  
  66. #define    MAKEDWORD(x,y)    ((((long)(x)) << 16) | ((long)(y)))
  67. #define GETLOWORD(x)    ((short)((x)&0xFFFF))
  68. #define GETHIWORD(x)    ((short)((x) >> 16))
  69.  
  70. /************************************************************************/
  71. /*                                                                        */
  72. /*    String Conversion                                                    */
  73. /*                                                                        */
  74. /************************************************************************/
  75.  
  76. extern unsigned char    *cvtc2p(unsigned char *, const char *);
  77. extern char                *cvtp2c(char *, const unsigned char *);
  78.  
  79. /************************************************************************/
  80. /*                                                                        */
  81. /*    Pascal string manipulation                                            */
  82. /*                                                                        */
  83. /************************************************************************/
  84.  
  85. extern unsigned char    *pstrcpy(unsigned char *, const unsigned char *);
  86. extern unsigned char    *pstrcat(unsigned char *, const unsigned char *);
  87. extern long                pstrcmp(const unsigned char *, const unsigned char *);
  88.  
  89. /************************************************************************/
  90. /*                                                                        */
  91. /*    Endian byte order utilities                                            */
  92. /*                                                                        */
  93. /************************************************************************/
  94.  
  95. /*
  96.  *    Byte order swap
  97.  */
  98.  
  99. extern unsigned short    SwapWord(unsigned short);
  100. extern unsigned long    SwapLong(unsigned long);
  101. extern float            SwapFloat(float);
  102. extern double            SwapDouble(double);
  103.  
  104. /*
  105.  *    Conversion to/from network order
  106.  */
  107.  
  108. #if OPT_NATIVEORDER == 1
  109.  
  110. #define    ESwapWord(x)    SwapWord(x)
  111. #define    ESwapLong(x)    SwapLong(x)
  112. #define    ESwapFloat(x)    SwapFloat(x)
  113. #define    ESwapDouble(x)    SwapDouble(x)
  114.  
  115. #define    NSwapWord(x)    (x)
  116. #define    NSwapLong(x)    (x)
  117. #define    NSwapFloat(x)    (x)
  118. #define    NSwapDouble(x)    (x)
  119.  
  120. #else
  121.  
  122. #define    NSwapWord(x)    (x)
  123. #define    NSwapLong(x)    (x)
  124. #define    NSwapFloat(x)    (x)
  125. #define    NSwapDouble(x)    (x)
  126.  
  127. #define    ESwapWord(x)    SwapWord(x)
  128. #define    ESwapLong(x)    SwapLong(x)
  129. #define    ESwapFloat(x)    SwapFloat(x)
  130. #define    ESwapDouble(x)    SwapDouble(x)
  131.  
  132. #endif
  133.  
  134.  
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138.  
  139. #if defined(__MWERKS__)
  140.     #if defined(macintosh)
  141.         #pragma options align=reset
  142.     #endif
  143.     #if defined(__INTEL__)
  144.         #pragma pack(pop)
  145.     #endif
  146. #endif
  147.  
  148. #endif /* __XDATAUTIL_H__ */
  149.